package com.hpeng.util;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface GenericDao<T, PK extends Serializable> {

	public T get(PK id);

	@Transactional(readOnly = true)
	public List<T> getAll();

	public T save(T object);

	public T update(T object);

	public void saveAll(List<T> list);

	public void remove(PK id);

	//通过hql语句查询出集合
	@Transactional(readOnly = true)
	public List<T> getByHql(String hql);

	public Long count();

	//通过hql语句查出统计数
	public Long countByHql(String hql);

	//获取对象的List集合, 
	@Transactional(readOnly = true)
	public List<T> getAll(int firstResult, int maxResults);

	@Transactional(readOnly = true)
	public List<Object[]> queryByhql(String hql, int firstResult, int maxResults);
	
	
	//使用sql来获取list集合
	public List<T> getBySql(final String sql , final Class T);
	public boolean executeBySql(String sql)throws Exception;

	public void removeAllByIds(PK... ids);
	
	public void removeAllByEntities(Collection<T> entities);
	
	public Pagination<T> getPagination (String[] hql, Object[] values,int pageNumber);
	public Pagination<T> getPagination(String hql,  Object[] values,
			 int pageNumber);

}